<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>采购退货</title>
<link rel="stylesheet" type="text/css"
	href="extjs/resources/css/ext-all.css" />
<script type="text/javascript" src="extjs/ext-all.js"></script>
<script type="text/javascript" src="extjs/ext-lang-zh_CN.js"></script>
<script>
Ext.onReady(function(){
//Ext.BLANK_IMAGE_URL = "extjs/resources/themes/images/default/shared/blue-loading.gif";
	  Ext.QuickTips.init();
	windowst.show();
	findAll(1);
	
//	if(2>1)
		//alert("111");
});
	
	var fielmenu2=new Ext.menu.Menu({
		items:[{text:'采购入库转入'}]
	});
	var fielmenu3=new Ext.menu.Menu({
		items:[{text:'批号设定'},{text:'条码打印'},{text:'批次变更单价'}]
	});
	
	var toolbar=Ext.create('Ext.toolbar.Toolbar',{
		width:600,
		items:[
			{text:'上一页',handler:function(){
				grids.store.removeAll();
				findAll(pb.previouspage);}},
			{text:'下一页',handler:function(){
				grids.store.removeAll();
				findAll(pb.nextpage);}},
			{text:'保存',handler:function(){
				var i=0;
				Ext.each(Ext.pluck(grids.getStore().data.items,'data'), function(obj,i) {  
				//alert(obj.squantity);
				//alert(grids.store.getAt(i).get('weishengxiaosl'));
				grids.store.getAt(i).set('weishengxiaosl',parseInt(obj.squantity)+parseInt(obj.weishengxiaosl));
				//alert(grids.store.getAt(i).get('weishengxiaosl'));
			    });
				
				xggysdate();
				add();
				var is = Ext.getCmp('isdeduct').getValue();
				if(is=="是"){
					 

				}
				grids.store.removeAll();
				
				findAll(1);
				
			}},
			{text:'删除',handler:function(){
				cgthdelete();
				findAll(1);
			}},
			{text:'新建',handler:function(){
				empty();
			}},
			{text:'审核',handler:function(){
				shjsyfk();
				xgcount();
				xgthwckslUpdate();
				//grids.store.removeAll();
				 
				shenhe();}
			},
			{text:'取消审核',handler:function(){
				fsxgthwckslUpdate();
				fshjsyfk();
				fsxgcount();
				//grids.store.removeAll();
				fanshenhe();
				
				}
			},
		      ]
		
	});

//var cbstore = Ext.create('Ext.data.Store',{
	//fields:['id','name'],
	//data:[
	     // {"id":"1","name":"傻狗"},
	     // {"id":"2","name":"啦啦啦"},
	     // {"id":"3","name":"嘿嘿嘿"}
	     // ]
//});

var grids=Ext.create('Ext.grid.Panel',{
    
	 listeners:{
				containerdblclick: function(grid, e, eOpts){ //单击事件
	    					this.getStore().add({
	    					'prodid':'',
	    					'prodname':'',
	    					'prodsize':'',
	    					'eunit':'', 
	    					'squantity':'',
	    					'oldprice':'',
	    					'discount':'',
	    					'sprice':'',
	    					'amount':'',
	    					'taxrate':'',
	    					'taxamt':'',
	    					'amountatax':'',
	    					'zengpin':'',
	    					'itemremark':'',
	    					'trantype':'',
	    					'fromno':'',
	    					'weishengxiaosl':''
	    					});
    						
    					},
    					'itemdblclick':function(grid,rowIndex,e,i){
    						var record = grid.getSelectionModel().getSelection();
    						var srdid = record[0].get("squantity");
    						var weishengxiaosl = record[0].get("weishengxiaosl");
    						//loadck(srdid);
    						//alert(srdid);
    						//windows3.close();
    						//grid.store.getAt(i).set('weishengxiaosl',parseInt(srdid)+parseInt(weishengxiaosl));
    						//alert();
    						//var cor = grid.getSelectionModel().getSelection();
 							//如果是在GridPanel中，拿到record的方法为如下
 							//var record = grid.getSelectionModel().getSelected();
  							//调用record的set方法格式为
 
							//cor.set(weishengxiaosl,srdid);
    					}
					
			},plugins: [
        				Ext.create('Ext.grid.plugin.CellEditing', {
            				clicksToEdit: 1
        				})
    				],
    				
	columns: [
				 {header: '（栏号）',
	                    		xtype: 'rownumberer',
	                    		dataIndex: 'lh', 
	                    		width: 50,
								sortable: false
        					},
					
        		{ header: '物料编号',  dataIndex: 'prodid', width: 100,editor:{xtype:'textfield'}},
       			 { header: '物料名称', dataIndex: 'prodname',width: 120,fields: { xtype:'textfield',
				 	listeners:{
						focus:function(grid, e, eOpts){
								windows2.show();
								}
							
					}
				 } },
       				 { header: '规格型号', dataIndex: 'prodsize',editor:{xtype:'textfield'} },
					 { header: '单位名称', dataIndex: 'eunit',editor:{xtype:'textfield'} },
					 { header: '数量', dataIndex: 'squantity',editor:{xtype:'textfield'}
						// fields:cbstore
						
					 },
					 { header: '折扣前单价', dataIndex: 'oldprice',editor:{xtype:'textfield'} },
					 { header: '折数(%)', dataIndex: 'discount',editor:{xtype:'textfield'} },
					 { header: '单价', dataIndex: 'sprice',editor:{xtype:'textfield'} },
					 { header: '金额', dataIndex: 'amount',editor:{xtype:'textfield'} },
					 { header: '税率', dataIndex: 'taxrate',editor:{xtype:'textfield'} },
					 { header: '税额', dataIndex: 'taxamt',editor:{xtype:'textfield'} },
					 { header: '含税金额', dataIndex: 'amountatax',editor:{xtype:'textfield'} },
					
					 { header: '赠品', dataIndex: 'zengpin',editor:{xtype:'textfield'} },
					 { header: '分录备注', dataIndex: 'itemremark',editor:{xtype:'textfield'} },
					 { header: '来源单别', dataIndex: 'trantype',editor:{xtype:'textfield'} },
					 { header: '来源单号', dataIndex: 'fromno',editor:{xtype:'textfield'} },
					 { header: '未生效出库量', dataIndex: 'weishengxiaosl',editor:{xtype:'textfield'} 
					 	
					 }
   					 ],
   			 height: 130,
			 width:1971,
			 autoScroll:false,
			 
})

var filterPanel = Ext.create('Ext.panel.Panel', {
	
    bodyPadding: 6,  // 避免Panel中的子元素紧邻边框
    width: 1985,
	height:170,
    items:[grids],
	bbar:[{xtype:"label",text:'总金额:',width:90},
	{xtype:"textfield",disabled:true,width:90,margin:'0 180',value:'0.00'}
	],
});

var zhangkuan=Ext.create('Ext.form.Panel', {
    bodyPadding: 5,
	height:'100%',
	layout:"column",
	baseCls:'x-plain',
	items:[{
		 xtype: 'textfield',
        name: 'SalesMan',
		bodyPadding: 5,
        fieldLabel: '账款归属',
		width:250,
        labelWidth: 80,
        anchor: '100%',
			},{
		 xtype: 'datefield',
		 id: 'fukuandate',
        fieldLabel: '付款日期',
		style:'margin-left:19px',
		width:250,
        labelWidth: 80,
        anchor: '100%',
			},{
				fieldLabel: '付款条件',
				xtype:'combo',
             	name: 'IncludeRate',
             	displayField: 'name',
				labelWidth:80,
				width:140,
				valueField: 'abbr',
				store: Ext.create('Ext.data.Store', {
					fields: ['abbr', 'name'],
					data : [
    					{"abbr":"货到", "name":"货到"},
    					{"abbr":"次月", "name":"次月"},
    					{"abbr":"月结", "name":"月结"},
    					{"abbr":"其他", "name":"其他"}
						
				   ]
				}),
				value: '货到',
    			typeAhead: true,
    			mode: 'local',
    			triggerAction: 'all',
    			selectOnFocus:true,
			},{
				 xtype: 'textfield',
			        name: 'SalesMan',
					bodyPadding: 5,
			       // fieldLabel: '账款归属',
					width:95,
			        labelWidth: 60,
			        anchor: '100%',
			},{
				xtype:"label",text:'天',width:15
			},{
		 xtype: 'textfield',
		 id: 'zhangkuanmonth',
        fieldLabel: '账款月份',
		style:'margin-left:19px',
		width:250,
        labelWidth: 80,
        anchor: '100%',
			}],
	});
var  tableds=Ext.create('Ext.TabPanel',{
	width:"100%",
	height:230,
	autoScroll:true,
	bodyPadding: 5,
	items:[{title:'内容',autoScroll:true,items:[filterPanel]},{title:'账款',autoScroll:true,items:[zhangkuan]},{title:'备注',xtype:'textarea',id:'beizhu',fieldLabel: '备注',labelWidth: 30,}],
});


var formsg=Ext.create('Ext.form.Panel', {
	id:'fom',
    bodyPadding: 5,
	height:'100%',
	layout:"column",
	baseCls:'x-plain',
	items:[{
		 xtype: 'textfield',
        id: 'salesid',
		bodyPadding: 5,
        fieldLabel: '采购人员',
		width:250,
        labelWidth: 80,
        anchor: '100%',
			},{
		 xtype: 'textfield',
		 id: 'maker',
        fieldLabel: '制单人员',
		style:'margin-left:19px',
		width:250,
        labelWidth: 80,
        anchor: '100%',
			},{
		 xtype: 'textfield',
		 id: 'departname',
        fieldLabel: '所属部门',
		width:250,
        labelWidth: 80,
        anchor: '100%',
			},{
		 xtype: 'textfield',
		 id: 'permitter',
        fieldLabel: '复核人员',
		style:'margin-left:19px',
		width:250,
        labelWidth: 80,
        anchor: '100%',
			},{
		 xtype: 'textfield',
		 id: 'projectname',
        fieldLabel: '所属项目',
		width:250,
        labelWidth: 80,
        anchor: '100%',
			}],
	});



var forms=Ext.create('Ext.form.Panel', {
	id:'shang',
    bodyPadding: 5,
	height:'100%',
	layout:"column",
	baseCls:'x-plain',
	items:[
	{
		xtype: 'textfield',
		id: 'custid',
        fieldLabel: '供应商',
		width:250,
        labelWidth: 80,
		emptyText:'请输入客户',
        anchor: '100%',
			}
	,{
		style:'margin-left:9px;color:blue',
		xtype: 'datefield',
		id: 'billdate',
        fieldLabel: '单据日期',
		
		width:250,
        labelWidth: 70,
        anchor: '100%',
			},{
		 xtype: 'textfield',
		 id: 'custaddress',
        fieldLabel: '供应商地址',
		width:150,
        labelWidth: 80,
        anchor: '100%',
			},{
		 xtype: 'textfield',
		 id: 'dizhiton',
		width:99,
        labelWidth: 70,
		margin:"0 1",
        anchor: '100%',
			},{
			style:'margin-left:9px',
		 xtype: 'textfield',
		 id: 'billno',
		style:"color:blue;margin-left:9px",
        fieldLabel: '单据号码',
		width:250,
        labelWidth: 70,
        anchor: '100%',
			},{
				fieldLabel: '单价是否含税',
				xtype:'combo',
				id: 'priceoftax',
             	displayField: 'name',
				labelWidth:80,
				width:250,
				valueField: 'abbr',
				store: Ext.create('Ext.data.Store', {
					fields: ['abbr', 'name'],
					data : [
    					{"abbr":"含税", "name":"含税"},
    					{"abbr":"未税", "name":"未税"}
						
				   ]
				}),
				value: '含税',
    			typeAhead: true,
    			mode: 'local',
    			triggerAction: 'all',
    			selectOnFocus:true,
			},{
			style:'margin-left:9px',
		 xtype: 'textfield', //多行文本域
		 id: 'currid',
        fieldLabel: '币别',
        labelWidth: 70,
		width:250,
        anchor: '100%',
			},{
				 xtype: 'textfield',
				 id: 'wareid',
			        fieldLabel: '仓库',
					width:250,
					style:"color:blue",
			        labelWidth: 80,
			        anchor: '100%',
        			
	         	},{
			style:'margin-left:9px',
		 xtype: 'textfield', //多行文本域
		 id: 'exchrate',
        fieldLabel: '汇率',
        labelWidth: 70,
		width:250,
        anchor: '100%',
			},{
				fieldLabel: '重新入库',
				xtype:'combo',
				id: 'isdeduct',
             	displayField: 'name',
				labelWidth:80,
				width:250,
				valueField: 'abbr',
				store: Ext.create('Ext.data.Store', {
					fields: ['abbr', 'name'],
					data : [
    					{"abbr":"是", "name":"是"},
    					{"abbr":"否", "name":"否"}
						
				   ]
				}),
				value: '否',
    			typeAhead: true,
    			mode: 'local',
    			triggerAction: 'all',
    			selectOnFocus:true,
			},{
	             	fieldLabel: '国外贸易',
					xtype:'combo',
					id: 'guowaimaoyi',
					style:"margin-left:9px",
	             	displayField: 'name',
					labelWidth:70,
					width:250,
					
    				valueField: 'abbr',
					store: Ext.create('Ext.data.Store', {
						fields: ['abbr', 'name'],
    					data : [
        					{"abbr":"是", "name":"是"},
        					{"abbr":"否", "name":"否"}
							
					   ]
					}),
					value: '否',
        			typeAhead: true,
        			mode: 'local',
        			triggerAction: 'all',
        			selectOnFocus:true,
        			
	         	},{
		 xtype: 'textfield',
		 id: 'voucherno',
        fieldLabel: '凭证编号',
		width:250,
        labelWidth: 80,
        anchor: '100%',
			},tableds,formsg
	]
    
	
	
});

//winform窗口
	var windowst=new  Ext.Window({
		width:640,
		height:580,
		title:"采购退货单",
		closable:true,
		resizable:false, //设置是否可以改变大小
		draggable:true,
		anchor: '100%',
		items:[toolbar,forms],
		listeners : {
			activate : function() {
				
				
			}
		},
		bbar:[
		{xtype:"splitbutton",text:'转单',width:90,menu:fielmenu2},
		{xtype:"splitbutton",text:'功能',width:90,menu:fielmenu3}],
	});
	
	var windows2=new  Ext.Window({
		width:400,
		height:300,
		title:"物料选择",
		closable:true,
		resizable:false, //设置是否可以改变大小
		draggable:true,
		closeAction:"hide",
	});
	
	function  afronction(){
		var song=Ext.encode(forms.getForm().getValues());
		Ext.Ajax.request(   
           	 {  
            //被用来向服务器发起请求默认的url  
           		 url : "",  
           	 //请求时发送后台的参数,既可以是Json对象，也可以直接使用“name = value”形式的字符串  
          		  params :[{}],  
            //请求时使用的默认的http方法  
            method : "post",  
            //请求成功时回调函数  
            success : function() {  
                Ext.ux.Toast.msg("信息提示", "成功删除所选记录！");  
            },  
            //请求失败时回调函数  
            failure : function() {  
                Ext.ux.Toast.msg("信息提示", "信息删除出错，请联系管理员!");  
            }  
        }  
    );  
				alert(song);// 序列化表单
	}
//	Ext.getCmp('custid').setValue('1');
	var pb = null;
	function findAll(page) {
		
		
	//	var page = 1;
		//var song=Ext.encode(forms.getForm().getValues());
		Ext.Ajax.request({
			//被用来向服务器发起请求默认的url  
			url : "/cgthloady",
			//请求时发送后台的参数,既可以是Json对象，也可以直接使用“name = value”形式的字符串  
			params :{pagenum:page},
			//请求时使用的默认的http方法  
			method : "post",
			//请求成功时回调函数  
			success : function(data) {
			 pb=Ext.JSON.decode(data.responseText)
			//   alert(pp.tuihuocong) 
				Ext.getCmp('custid').setValue(pb.pagedata[0].custid);
				Ext.getCmp('custaddress').setValue(pb.pagedata[0].custaddress);
				Ext.getCmp('billdate').setValue(pb.pagedata[0].billdate);
				Ext.getCmp('billno').setValue(pb.pagedata[0].billno);
				Ext.getCmp('priceoftax').setValue(pb.pagedata[0].priceoftax);
				Ext.getCmp('currid').setValue(pb.pagedata[0].currid);
				Ext.getCmp('exchrate').setValue(pb.pagedata[0].exchrate);
				Ext.getCmp('wareid').setValue(pb.pagedata[0].wareid);
				Ext.getCmp('isdeduct').setValue(pb.pagedata[0].isdeduct);
				Ext.getCmp('voucherno').setValue(pb.pagedata[0].voucherno);
				Ext.getCmp('salesid').setValue(pb.pagedata[0].salesid);
				
				Ext.getCmp('maker').setValue(pb.pagedata[0].maker);
				Ext.getCmp('departname').setValue(pb.pagedata[0].departname);
				Ext.getCmp('permitter').setValue(pb.pagedata[0].permitter);
				Ext.getCmp('projectname').setValue(pb.pagedata[0].projectname);
				Ext.getCmp('beizhu').setValue(pb.pagedata[0].beizhu);
				Ext.getCmp('fukuandate').setValue(pb.pagedata[0].fukuandate);
				Ext.getCmp('zhangkuanmonth').setValue(pb.pagedata[0].zhangkuanmonth);
				grids.getStore().add(pb.pagedata[0].tuihuocong);
	//			Ext.ux.Toast.msg("信息提示", "成功删除所选记录！");
			},
			//请求失败时回调函数  
			failure : function() {
				//Ext.ux.Toast.msg("信息提示", "信息删除出错，请联系管理员!");
				Ext.Msg.alert("信息提示", "信息删除出错，请联系管理员!");
			}
		});
	}
	function add(){
		//var weishengxiao = Ext.getCmp('weishengxiaosl').getValue();
		var tuihuozhu = {
				custid:Ext.getCmp('custid').getValue(),	
				custaddress:Ext.getCmp('custaddress').getValue(),	
				billdate:'2017-06-09',	
				billno:Ext.getCmp('billno').getValue(),	
				priceoftax:Ext.getCmp('priceoftax').getValue(),	
				currid:Ext.getCmp('currid').getValue(),
				exchrate:Ext.getCmp('exchrate').getValue(),	
				wareid:Ext.getCmp('wareid').getValue(),	
				isdeduct:Ext.getCmp('isdeduct').getValue(),	
				voucherno:Ext.getCmp('voucherno').getValue(),	
				salesid:Ext.getCmp('salesid').getValue(),	
				maker:Ext.getCmp('maker').getValue(),	
				isshenhe:'未审核',
				departname:Ext.getCmp('departname').getValue(),	
				permitter:Ext.getCmp('permitter').getValue(),	
				projectname:Ext.getCmp('projectname').getValue(),	
				beizhu:Ext.getCmp('beizhu').getValue(),	
				fukuandate:'2017-09-09',	
				zhangkuanmonth:Ext.getCmp('zhangkuanmonth').getValue(),
				//weishengxiaosl:weishengxiao ,
				tuihuocong:Ext.pluck(grids.getStore().data.items,"data"),
		}
		//alert(JSON.stringify(tuihuozhu));
		Ext.Ajax.request(   
	           	 {  
	            //被用来向服务器发起请求默认的url  
	           		 url : "/cgthadd",  
	           	 //请求时发送后台的参数,既可以是Json对象，也可以直接使用“name = value”形式的字符串  
	        	  headers: {'Content-Type':'application/json'},
	          		  params :JSON.stringify(tuihuozhu),  
	            //请求时使用的默认的http方法  
	            method : "post",  
	            //请求成功时回调函数  
	            success : function() {  
	            	Ext.Msg.alert("信息提示", "新增成功");  
	            },  
	            //请求失败时回调函数  
	            failure : function() {  
	            	Ext.Msg.alert("信息提示", "新增失败");  
	            }  
	        }  
	    );  
	}
	function cgthdelete (){
		var billno = Ext.getCmp('billno').getValue();
		//alert(billno)
		Ext.Ajax.request({
			url:"/cgthdelete",
			params:{"billno":billno},
			method:"post",
			success:function(){
				Ext.Msg.alert("信息提示","删除成功");
			},
			failure:function(){
				Ext.Msg.alert("信息提示", "删除失败"); 
			}
		
		});
	}
	function empty(){
		Ext.getCmp('shang').getForm().reset();
		Ext.getCmp('fom').getForm().reset();
		grids.store.removeAll();
		
	}
	function shenhe(){
		var billno = Ext.getCmp('billno').getValue();
		Ext.Ajax.request({
			url:'/cgthupdate1',
			params:{"billno":billno},
			method:"post",
			success:function(){
				Ext.Msg.alert("信息提示","审核成功");
			},
			failure:function(){
				Ext.Msg.alert("信息提示","审核失败");
			}
		});
	}
	function fanshenhe(){
		var billno = Ext.getCmp('billno').getValue();
		Ext.Ajax.request({
			url:'/cgthupdate2',
			params:{"billno":billno},
			method:"post",
			success:function(){
				Ext.Msg.alert("信息提示","取消审核成功");
			},
			failure:function(){
				Ext.Msg.alert("信息提示","取消审核失败");
			}
		});
	}
	//修改采购订单中的单况
	function xgcgdddkUpdate(){
		
	}
	//修改采购订单中的未入库量
	function xgcgddwrklUpdate(){
		
	}
	//修改供应商主文件的最近退货日期
	function xggysdate(){
		var gysname =  Ext.getCmp('custid').getValue();
		Ext.Ajax.request({
			url:'/cgthgysdate',
			params:{"gysname":gysname},
			method:"post",
			success:function(){
				//Ext.Msg.alert("信息提示","取消审核成功");
			},
			failure:function(){
				//Ext.Msg.alert("信息提示","取消审核失败");
			}
		});
	}
	//修改库存数量
	function xgcount(){
		var i=0;
		Ext.each(Ext.pluck(grids.getStore().data.items,'data'), function(obj,i) {  
		var wlbh= grids.store.getAt(i).get('prodid');
		var sl= grids.store.getAt(i).get('squantity');
		//alert(wlbh);
		//alert(sl);
		Ext.Ajax.request({
			url:'/cgthxgckcounts',
			params:{
				"number":sl,
				"prodId":wlbh
				},
			method:"post",
			success:function(){
				//Ext.Msg.alert("信息提示","取消审核成功");
			},
			failure:function(){
				//Ext.Msg.alert("信息提示","取消审核失败");
			}
		});
	    });
		
	}
	//反审核修改数量
	function fsxgcount(){
		var i=0;
		Ext.each(Ext.pluck(grids.getStore().data.items,'data'), function(obj,i) {  
		var wlbh= grids.store.getAt(i).get('prodid');
		var sl= grids.store.getAt(i).get('squantity');
		//alert(wlbh);
		//alert(sl);
		Ext.Ajax.request({
			url:'/fscgthxgckcounts',
			params:{
				"number":sl,
				"prodId":wlbh
				},
			method:"post",
			success:function(){
				//Ext.Msg.alert("信息提示","取消审核成功");
			},
			failure:function(){
				//Ext.Msg.alert("信息提示","取消审核失败");
			}
		});
	    });
	}
	function add1(){
		//var weishengxiao = Ext.getCmp('weishengxiaosl').getValue();
		var tuihuozhu = {
				custid:Ext.getCmp('custid').getValue(),	
				custaddress:Ext.getCmp('custaddress').getValue(),	
				billdate:'2017-06-09',	
				billno:Ext.getCmp('billno').getValue(),	
				priceoftax:Ext.getCmp('priceoftax').getValue(),	
				currid:Ext.getCmp('currid').getValue(),
				exchrate:Ext.getCmp('exchrate').getValue(),	
				wareid:Ext.getCmp('wareid').getValue(),	
				isdeduct:Ext.getCmp('isdeduct').getValue(),	
				voucherno:Ext.getCmp('voucherno').getValue(),	
				salesid:Ext.getCmp('salesid').getValue(),	
				maker:Ext.getCmp('maker').getValue(),	
				isshenhe:'未审核',
				departname:Ext.getCmp('departname').getValue(),	
				permitter:Ext.getCmp('permitter').getValue(),	
				projectname:Ext.getCmp('projectname').getValue(),	
				beizhu:Ext.getCmp('beizhu').getValue(),	
				fukuandate:'2017-09-09',	
				zhangkuanmonth:Ext.getCmp('zhangkuanmonth').getValue(),
				//weishengxiaosl:weishengxiao ,
				tuihuocong:Ext.pluck(grids.getStore().data.items,"data"),
		}
		//alert(JSON.stringify(tuihuozhu));
		Ext.Ajax.request(   
	           	 {  
	            //被用来向服务器发起请求默认的url  
	           		 url : "/cgthadd",  
	           	 //请求时发送后台的参数,既可以是Json对象，也可以直接使用“name = value”形式的字符串  
	        	  headers: {'Content-Type':'application/json'},
	          		  params :JSON.stringify(tuihuozhu),  
	            //请求时使用的默认的http方法  
	            method : "post",  
	            //请求成功时回调函数  
	            success : function() {  
	            	//Ext.Msg.alert("信息提示", "新增成功");  
	            },  
	            //请求失败时回调函数  
	            failure : function() {  
	            	//Ext.Msg.alert("信息提示", "新增失败");  
	            }  
	        }  
	    );  
	}
	//审核时修改退货未出库数量
	function xgthwckslUpdate(){
		var i=0;
		Ext.each(Ext.pluck(grids.getStore().data.items,'data'), function(obj,i) {  
		//alert(obj.squantity);
		//alert(grids.store.getAt(i).get('weishengxiaosl'));
		grids.store.getAt(i).set('weishengxiaosl',parseInt(obj.weishengxiaosl)-parseInt(obj.squantity));
		//alert(grids.store.getAt(i).get('weishengxiaosl'));
	    });
		add1();
	}
	//反审核时修改退货未出库数量
	function fsxgthwckslUpdate(){
		var i=0;
		Ext.each(Ext.pluck(grids.getStore().data.items,'data'), function(obj,i) {  
		//alert(obj.squantity);
		//alert(grids.store.getAt(i).get('weishengxiaosl'));
		grids.store.getAt(i).set('weishengxiaosl',parseInt(obj.weishengxiaosl)-parseInt(obj.squantity));
		//alert(grids.store.getAt(i).get('weishengxiaosl'));
	    });
		add1();
	}
	//审核时计算期末应付款
	function shjsyfk(){
		var i=0;
		var total = 0;
		var gysname = Ext.getCmp('custid').getValue();
		Ext.each(Ext.pluck(grids.getStore().data.items,'data'), function(obj,i) {  
		//alert(obj.squantity);
		//alert(grids.store.getAt(i).get('weishengxiaosl'));
		//grids.store.getAt(i).set('weishengxiaosl',parseInt(obj.weishengxiaosl)-parseInt(obj.squantity));
		var jine = grids.store.getAt(i).get('amount');
		total = jine+total;
	    });
		Ext.Ajax.request({
			url:'/shxggyszwjxinxi',
			params:{
				"qimyingfuk":total,
				"GYSname":gysname
				},
			method:"post",
			success:function(){
				//Ext.Msg.alert("信息提示","取消审核成功");
			},
			failure:function(){
				//Ext.Msg.alert("信息提示","取消审核失败");
			}
		});
		
		
	}
	function fshjsyfk(){
		var i=0;
		var total = 0;
		var gysname = Ext.getCmp('custid').getValue();
		Ext.each(Ext.pluck(grids.getStore().data.items,'data'), function(obj,i) {  
		//alert(obj.squantity);
		//alert(grids.store.getAt(i).get('weishengxiaosl'));
		//grids.store.getAt(i).set('weishengxiaosl',parseInt(obj.weishengxiaosl)-parseInt(obj.squantity));
		var jine = grids.store.getAt(i).get('amount');
		total = jine+total;
	    });
		Ext.Ajax.request({
			url:'/fshxggyszwjxinxi',
			params:{
				"qimyingfuk":total,
				"GYSname":gysname
				},
			method:"post",
			success:function(){
				//Ext.Msg.alert("信息提示","取消审核成功");
			},
			failure:function(){
				//Ext.Msg.alert("信息提示","取消审核失败");
			}
		});
		
		
	}
</script>
</head>

<body>
</body>
</html>